import http from '@/utils/http'

const BASE_URL = '/asset/consumable/tracks'

export interface ConsumableTracksResp {
  id: string
  consumableId: string
  count: string
  change: string
  userId: string
  type: string
  description: string
  purchasedDate: string
  expiredDate: string
  createUser: string
  createTime: string
  updateUser: string
  updateTime: string
  createUserString: string
  updateUserString: string
  disabled: boolean
}
export interface ConsumableTracksDetailResp {
  id: string
  consumableId: string
  count: string
  change: string
  userId: string
  type: string
  description: string
  purchasedDate: string
  expiredDate: string
  createUser: string
  createTime: string
  updateUser: string
  updateTime: string
  createUserString: string
  updateUserString: string
}
export interface ConsumableTracksQuery {
  consumableId: string | undefined
  count: string | undefined
  change: string | undefined
  userId: string | undefined
  type: string | undefined
  purchasedDate: string | undefined
  expiredDate: string | undefined
  sort: Array<string>
}
export interface ConsumableTracksPageQuery extends ConsumableTracksQuery, PageQuery {}

/** @desc 查询耗材履历列表 */
export function listConsumableTracks(query: ConsumableTracksPageQuery) {
  return http.get<PageRes<ConsumableTracksResp[]>>(`${BASE_URL}`, query)
}

/** @desc 查询耗材履历详情 */
export function getConsumableTracks(id: string) {
  return http.get<ConsumableTracksDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增耗材履历 */
export function addConsumableTracks(data: any) {
  return http.post(`${BASE_URL}`, data)
}

/** @desc 修改耗材履历 */
export function updateConsumableTracks(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除耗材履历 */
export function deleteConsumableTracks(id: string) {
  return http.del(`${BASE_URL}/${id}`)
}

/** @desc 导出耗材履历 */
export function exportConsumableTracks(query: ConsumableTracksQuery) {
  return http.download(`${BASE_URL}/export`, query)
}
